

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
		<script>
			function isEmpty(obj){
			    if(typeof obj == "undefined" || obj == null || obj == ""){
			        return true;
			    }else{
			        return false;
			    }
			}


			function num(a,b,c,f) {
				 
				 var sum=0;

				 if (a + b + c == 0) {
				 	return 1;
				 }

				 if (isEmpty(f)) {

				 	sum = num(a-1,b,c,1) + num(a,b-1,c,2) + num(a,b,c-1,3);

				 }
				 if (f==1) {
				 	 
				 	if (b <= 0 && c > 0 ) {
				 		sum =   num(a,b,c-1,3);
				 	}else if(c <= 0 && b > 0  ) {
				 		sum =  num(a,b-1,c,2) ;
				 	}else if(c > 0 && b > 0 ) {
				 		sum =  num(a,b-1,c,2) + num(a,b,c-1,3);
				 	}
				 }


				 if (f==2) {

					if (a <= 0 && c > 0 ) {
				 		sum = num(a,b,c-1,3);
				 	}else if(c <= 0 && a > 0) {
				 		sum = num(a-1,b,c,1) ;
				 	}else if(c > 0 && a > 0 ) {
						sum = num(a-1,b,c,1) +   num(a,b,c-1,3);
				 	}
				 	


				 }

				 if (f==3) {
				 	if (a <= 0 && b > 0) {
				 		sum =  num(a,b-1,c,2);
				 	}else if(b <= 0 && a > 0) {
				 		sum =  num(a-1,b,c,1) ;
				 	}else if(b > 0 && a > 0 ){
						sum =  num(a-1,b,c,1) + num(a,b-1,c,2);
				 	}

				 	
				 }
				 // alert(sum);

				 return sum;
			}
			alert(num(15,15,15));
			


		</script>
</body>
</html>